package com.schoolcardinfo.biz.impl;

import java.util.ArrayList;
import java.util.List;

import com.schoolcardinfo.beans.ChangeIdInfo;
import com.schoolcardinfo.biz.IChangeIdInfoBiz;
import com.schoolcardinfo.dao.DBHelper;

public class ChangeIdInfoBizImpl implements IChangeIdInfoBiz{
	private DBHelper db=new DBHelper();
	@Override
	public int addChangeIdInfo(ChangeIdInfo ci) {
		String sql="insert into changeIdInfo values(null,?,?,?)";
		List<Object> params=new ArrayList<Object>();
		params.add(ci.getCtime());
		params.add(ci.getStudentId());
		params.add(ci.getCname());
		int result=db.update(sql, params);
		return result;
	}

	@Override
	public List<ChangeIdInfo> selectChangeIdInfo(int studentId) {
		String sql="";
		if(studentId==0){
			sql="select * from changeIdInfo";
		}else{
			sql="select * from changeIdInfo where studentId="+studentId;
		}
		List<ChangeIdInfo> list=db.find(sql, null, ChangeIdInfo.class);
		if(list.size()>0){
			return list;
		}else{
			return null;
		}
	}

}
